﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Xml.Linq;

namespace BaseTypesLib.Model.Backgrounds
{
    public class SolidColorBackground:Background
    {
        private Color color;
        public Color Color 
        {
            get { return color; }
            set
            {
                if (color != value)
                {
                    color = value;
                    OnPropertyChanged("Color");
                }
            }
        }
        public override string ToString()
        {
            return "Solid";
        }
        public override XElement GetXml()
        {
            XElement elem = base.GetXml();
            elem.SetAttributeValue("Color", Color);
            return elem;
        }
        protected override void FromXmlElement(XElement elem)
        {
            base.FromXmlElement(elem);
            var c = elem.Attributes("Color").FirstOrDefault();
            if (c != null)
                Color = (Color)ColorConverter.ConvertFromString(c.Value);

        }
    }
}
